import 'package:kong/domain/model/user.dart';
import 'package:kong/domain/repository/api_repository.dart';
import 'package:kong/domain/model/response/login.dart';
import 'package:kong/domain/model/request/login.dart';
import 'package:kong/domain/exception/auth_exception.dart';

class ApiRepositoryImpl extends ApiRepositoryInterface {
  @override
  Future<User> getUserFromToken(String token) async {
    if (token == '123456') {
      return User(
        username: '13155556666',
        nickname: 'teedy',
        avatar: 'assets/images/app_icon.png',
      );
    }
    throw AuthException();
  }

  @override
  Future<LoginResponse> login(LoginRequest loginRequest) async {
    if (loginRequest.username == '13155556666' &&
        loginRequest.password == '123456') {
      return LoginResponse(
        '123456',
        User(
          username: '13155556666',
          nickname: 'teedy',
          avatar: 'assets/images/app_icon.png',
        ),
      );
    }
    throw AuthException();
  }

  @override
  Future<void> logout(String token) async {
    return;
  }
}
